<template>
<div>
  <h2>我是App组件:{{count}}</h2>
  <Count ref="childComp"></Count>
</div>
</template>

<script>
import Count from "@/components/Count";
export default {
    name : "App",
  components: {Count},
  data(){
      return{
        count:0,
      }
  },
  mounted() {
      // 执行一次
      this.$refs.childComp.$once("changeCount",this.changeCount)

      this.$refs.childComp.$on("changeCount",this.changeCount)

  },
  methods:{
    changeCount(value){
      this.count += value
    }
  }
}
</script>


<style></style>